package com.anywhere.freightman.order.dao;

import com.anywhere.freightman.common.BaseMapper;
import com.anywhere.freightman.common.entity.ReportDayCount;
import com.anywhere.freightman.common.entity.order.DriverCarEntity;
import com.anywhere.freightman.common.enumeration.AcceptedState;
import com.anywhere.freightman.common.enumeration.WaybillStatus;
import com.anywhere.freightman.common.enumeration.WaybillType;
import com.anywhere.freightman.order.model.CarDriverModel;
import com.anywhere.freightman.order.model.WaybillModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface WaybillDao extends BaseMapper<WaybillModel> {
    WaybillModel getByNo(@Param("orderNo") String orderNo);

    WaybillModel getByCode(@Param("code") String code);

    List<DriverCarEntity> getListCarAndDriver(@Param("orderNo") String orderNo);

    void insertCarAndDriver(@Param("orderNo") String orderNo,
                            @Param("carId") Long carId,
                            @Param("driverId") Long driverId,
                            @Param("trailerId") Long trailerId,
                            @Param("price") Double price);

    void accessCarAndDriver(@Param("orderNo") String orderNo,
                            @Param("carId") Long carId,
                            @Param("driverId") Long driverId,
                            @Param("price") Double price);

    void deleteCarDriver(@Param("id") Long id);

    List<WaybillModel> getList(@Param("orderNo") String orderNo,
                               @Param("type") WaybillType type,
                               @Param("status") WaybillStatus... status);

    CarDriverModel getCarDriverModel(@Param("id") Long id);

    void saveCarDriverModel(@Param("id") long id,
                            @Param("status") AcceptedState status);

    void removeCarDriverWithNoAccepted(@Param("orderNo") String orderNo);

    List<WaybillModel> getListByCompanyId(@Param("companyId") Long companyId);

    List<Map> getReportList(@Param("dateFormat") String dateFormat,
                            @Param("companyId") Long companyId,
                            @Param("startTime") Date startTime,
                            @Param("endTime") Date endTime);

    List<ReportDayCount> getReportCount(@Param("companyId") Long companyId,
                                        @Param("startTime") String startTime,
                                        @Param("endTime") String endTime,
                                        @Param("shipper") String shipper,
                                        @Param("receiver") String receiver);

    List<WaybillModel> getListByExOrderNo(@Param("exOrderNo") String exOrderNo);

    List<WaybillModel> getOwnerList(@Param("driverId") long driverId,
                                    @Param("orderNo") String orderNo,
                                    @Param("type") WaybillType type);
}
